{literal}
<script language="javascript">
<!--
    iLastId = 1;

    function fSubmit(){
        oForm = document.getElementById('genre_form');
        oNewGenreField = document.getElementById('new_genre');
        if (oNewGenreField.value != '')
        {
            addGenre();
            return false;
        }

        return true;
    }

    function noGenrePrint()
    {
        oTable = document.getElementById('genres_table');
        iIndex = oTable.rows.length;
        if (iIndex == 5){
            oRow = oTable.insertRow(2);
            oRow.setAttribute('id', 'noGenre');
            oTd = oRow.insertCell(0);
            oTd.className = 'row1';
            oTd.style.textAlign = "center";
              {/literal}
            oTd.innerHTML = "{language text="there_are_no_genres_yet"}";
            {literal}
        }else{
            oRow = document.getElementById('noGenre');
            if (oRow){
                oTable.deleteRow(oRow.rowIndex);
            }
        }
    }

    function addGenre()
    {
        oNewGenreField = document.getElementById('new_genre');
        if (oNewGenreField.value == '')
        {
            alert('Please specify new genre name!');
            oNewGenreField.focus();
            return false;
        }
        oTable = document.getElementById('genres_table');
        iIndex = oTable.rows.length - 3;
        oRow = oTable.insertRow(iIndex);
        oRow.setAttribute('id', iLastId);

        oTd = oRow.insertCell(0);
        oTd.className = 'row1';
        oInputElement = document.createElement('input');
        oInputElement.setAttribute('type', 'text');
        oInputElement.setAttribute('name', 'genre[new' + iLastId + ']');
        oInputElement.setAttribute('value', oNewGenreField.value);
        oTd.appendChild(oInputElement);

        oTd = oRow.insertCell(1);
        oTd.className = 'row1';
        {/literal}
        oTd.innerHTML = '<a href="#" onclick="return deleteGenre(' + iLastId + ')">{language text="delete_383"}</a>';
		{literal}
        iLastId++;
        oNewGenreField.value = '';
        oNewGenreField.focus();
        noGenrePrint();
        return true;
    }

    function deleteGenre(iId)
    {
    	{/literal}
        if (!confirm('{language text="do_you_really_want_to_delete_this_g"}'))
        {literal}
        {
            return false;
        }
        oTable = document.getElementById('genres_table');
        oRow = document.getElementById(iId);
        oTable.deleteRow(oRow.rowIndex);
        noGenrePrint();
        return false;
    }

    function deleteOldGenre(iGenreId)
    {
    	{/literal}
        if (!confirm('{language text="do_you_really_want_to_delete_this_g"}'))
        {literal}
        {
            return false;
        }
        oForm = document.getElementById('genre_form');
        oNewHidden = document.createElement('input');
        oNewHidden.setAttribute('type', 'hidden');
        oNewHidden.setAttribute('name', 'delete[]');
        oNewHidden.setAttribute('value', iGenreId);
        oForm.appendChild(oNewHidden);
        oTable = document.getElementById('genres_table');
        oTr = document.getElementById('old' + iGenreId);
        oTable.deleteRow(oTr.rowIndex);
        noGenrePrint();
        return false;
    }
-->
</script>
{/literal}
<form id="genre_form" action="{url link='current'}" method="post">
<table cellspacing="0" width="100%" class="forumline" id="genres_table">
    <tr>
        <td class="row-header" colspan="2"><span>{language text="genres_management"}</span></td>
    </tr>
    <tr>
        <td style="font-size:9pt;" class="row1" colspan="2">
            {language text="add_new_genre"}: <input type="text" id="new_genre" name="genre_new_field" value="" size="32"/> <input type="submit" name="act[add]" value="{language text="add"}" />
        </td>
    </tr>
    <tr>
        <th style="font-size:9pt;">
            <span> {language text="genre"} </span>
        </th>
        <th style="text-align:center;font-size:9pt;">
            <span> {language text="actions"} </span>
        </th>
    </tr>
	{foreach from=$aItems item=aItem name=aitems key=iKey}
    <tr id="old{$aItem.genre_id}">
        <td style="font-size:9pt;" class="row1{if $iKey is odd}b{/if}">
            <input type="text" name="genre[{$aItem.genre_id}]" value="{language translate=$aItem.genre_name}" size="32"/>
        </td>
        <td style="font-size:9pt; text-align:center;" class="row1{if $iKey is odd}b{/if}">
			<a class="link_action" href="{url link='admin.music.genre' act=del_genre id=$aItem.genre_id}" onclick="return confirm('{language text="do_you_really_want_to_delete_this_g"}');">[ {language text="delete"} ]</a>
			<a class="link_action" href="{url link='admin.language.add-phrase' translate=$aItem.genre_name|base64}">[ {language text='Mod_Language.translate'} ]</a>
        </td>
    </tr>
	{/foreach}
    <tr>
        <td style="padding:5px; text-align:center;" class="catBottom" colspan="2">
            <input type="submit" name="act[save]" value="{language text="save_changes_1233"}" />
        </td>
    </tr>
<script language="javascript">
    noGenrePrint();
</script>
</table>
</form>